//
//  TextCheck.m
//  EduOnLine
//
//  Created by Mac on 2019/11/14.
//  Copyright © 2019 eduonline. All rights reserved.
//

#import "TextCheck.h"

@implementation TextCheck

#pragma 正则匹配手机号
+ (BOOL)checkTelNumber:(NSString *) telNumber
{
    NSString *pattern = @"^1+[3456789]+\\d{9}$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
    BOOL isMatch = [pred evaluateWithObject:telNumber];
    isMatch = telNumber.length > 11? NO : isMatch;
    return isMatch;
}

#pragma 正则匹配固定电话
+ (BOOL)checkTelephoneNumber:(NSString *)telNumber{
    NSString *pattern = @"^(0\\d{2,3}-\\d{7,8}(-\\d{1,4}){0,1})|(((13[0-9])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8})$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
    BOOL isMatch = [pred evaluateWithObject:telNumber];
    isMatch = telNumber.length > 18? NO : isMatch;
    return isMatch;
}

#pragma 正则匹配用户密码6-18位数字和字母组合
+ (BOOL)checkPassword:(NSString *) password
{
    NSString *pattern = @"^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9]{6,18}";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
    BOOL isMatch = [pred evaluateWithObject:password];
    return isMatch;
    
}

#pragma mark -- 正则匹配17位车架号
+ (BOOL)checkCheJiaNumber:(NSString *)carNumber{
    NSString *bankNum=@"^[0-9A-Za-z]{17}";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",bankNum];
    BOOL isMatch = [pred evaluateWithObject:carNumber];
    return isMatch;
}



@end
